export const API_RECEIVE_DATA = 'https://manage.carnoc.com/task/weixin-task/receive-we-chat-data';
export const API_NICKNAME = 'https://manage.carnoc.com/task/weixin-task/get-wechat-nickname';

// export const API_RECEIVE_DATA = 'http://manage2.carnoc.com/task/weixin-task/receive-we-chat-data';
// export const API_NICKNAME = 'http://manage2.carnoc.com/task/weixin-task/get-wechat-nickname';

/**
 * @title 更新缓存
 * @author start2004
 * @since 2024-08-14
 *
 * @param  {string} key 键值
 * @param {mixed} value 缓存数据
 * @return {null}
 */
export async function SetStorage(key, value) {
  await chrome.storage.local.set({ [key]: value });
}

/**
 * @title 获取缓存
 * @author start2004
 * @since 2024-08-14
 *
 * @param {string} key 缓存键值
 * @return {mixed} 键值对应数据
 */
export async function GetStorage(key) {
  const result = await chrome.storage.local.get(key);

  /**
   * @return
   */
  return result[key];
}

/**
 * @title 删除缓存数据
 * @author start2004
 * @since 2024-09-23
 *
 * @param {string} key 缓存键值
 * @return {null}
 */
export async function RemoveStorage(key) {
  await chrome.storage.local.remove(key);
}

/**
 * @title 获取请求页码
 * @author start2004
 * @since 2025-03-06
 */
export async function GetRequestPage(){
  let requestPage = await GetStorage("request_page");
  if(requestPage === undefined) {
    requestPage = {
      start: 0,
      now: 0,
      end: 0,
      nickname: ""
    };
  } else {}
  // console.log(requestPage);

  return requestPage;
}